{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Call Microservice API for Reuters Document Similarity Model\n",
    "\n",
    "**You must run doc_similarity_reuters.ipynb first**\n",
    "\n",
    "Call the recommend service to get similar documents to document 6003"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n",
      "{   u'recommended': [   {   u'item': 17254, u'score': 0.5830801725387573},\n",
      "                        {   u'item': 17289, u'score': 0.5830801725387573},\n",
      "                        {   u'item': 17359, u'score': 0.5305154919624329},\n",
      "                        {   u'item': 3430, u'score': 0.5303963124752045}]}\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "import json\n",
    "import pprint\n",
    "params = {}\n",
    "params[\"user_id\"] = 1\n",
    "params[\"recent_interactions\"] = \"6023\"\n",
    "params[\"limit\"] = 4\n",
    "params[\"client\"] = \"reuters\"\n",
    "r = requests.get(\"http://127.0.0.1:5000/recommend\",params=params)\n",
    "print r.status_code\n",
    "j = json.loads(r.text)\n",
    "pp = pprint.PrettyPrinter(indent=4)\n",
    "pp.pprint(j)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
